package com.webchat.ugc.messaegqueue.consumer.rocketmq;

import com.fasterxml.jackson.core.type.TypeReference;
import com.webchat.common.enums.messagequeue.MessageQueueEnum;
import com.webchat.common.service.messagequeue.producer.MessageQueueProducer;
import com.webchat.common.util.JsonUtil;
import com.webchat.domain.vo.dto.mall.im.NettyServerMessageDTO;
import com.webchat.domain.vo.dto.mall.im.UgcServerMessageDTO;
import com.webchat.ugc.messaegqueue.service.MallIMessageConsumeService;
import com.webchat.ugc.service.ChatMessageService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.locationtech.jts.util.Assert;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;


/**
 *
 */
@Component
@RocketMQMessageListener(consumerGroup = "web_chat_ugc",
                         topic = "netty_server_chat_msg",
                         selectorExpression = "im_chat")
public class NettyServerRocketMQConsumer implements RocketMQListener<String> {

    @Autowired
    private MallIMessageConsumeService mallIMessageConsumeService;

    /**
     * 处理来自IM 对话相关消息
     *
     * @param message
     */
    @Override
    public void onMessage(String message) {
        System.out.println("Received message: " + message);
        mallIMessageConsumeService.doConsumeMessage(message);
    }
}